# _*_ coding: utf-8 _*_

from odoo import models, fields, api, _
from odoo.exceptions import UserError


class Picking(models.Model):
    _inherit = "stock.picking"

    @api.multi
    def do_new_transfer(self):
        for picking in self:
            if picking.origin:
                sale_order = self.env["sale.order"].search([("name", "=", self.origin)])
                if sale_order and not sale_order.price_confirmed:
                    raise UserError(_('Price unconfirmed,plaease confirm price before validate !'))
        return super(Picking, self).do_new_transfer()
